package com.example.yy.helloword0001;

import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.PopupWindow;

public class PopupWindowActivity extends AppCompatActivity implements View.OnClickListener {
    private Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

    // popupWindow 菜单

        super.onCreate(savedInstanceState);
        setContentView(R.layout.popup_window);

        button = findViewById(R.id.button);
        button.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        //获取自定义，菜单布局文件
        View inflate = getLayoutInflater().inflate(R.layout.popup_window_layout,null,false);

        //创建popupWindow 的实例
        PopupWindow popupWindow = new PopupWindow(inflate, ActionBar.LayoutParams.WRAP_CONTENT,ActionBar.LayoutParams.WRAP_CONTENT,true);
        //显示在button 下面
        popupWindow.showAsDropDown(button,0,0);
    }
}
